<?php
namespace bee;
/*
define("PAGE_TYPE_FORM",                1);
define("PAGE_TYPE_PAGE",                2);
define("PAGE_TYPE_SPECIAL",             3);
define("PAGE_TYPE_SPECIAL_APP",         4);
*/
/**
 *
 * @author dzelenika
 *
 */
class app implements Isingleton
{

  const PAGE_TYPE_FORM                  = 1;
  const PAGE_TYPE_PAGE                  = 2;
  const PAGE_TYPE_SPECIAL               = 3;
  const PAGE_TYPE_SPECIAL_APP           = 4;


  protected $formType;
  use Tsingleton;

  public function getFormType()
  {
    return $this->formType;
  }

  /**
   *
   * @return app
   */
  public static function getInstance()
  {
  	return static::__getInstance();
  }

  protected function __construct()
  {
    //die(request::getValue("__form", ""));
    $cfg = config::getInstance();
    if(request::getValue("__form", ""))
    {
      $this->curentForm        = request::getValue("__form", "");
      $this->formType          = app::PAGE_TYPE_FORM;
      $toSession               = true;
    } else if(request::getValue("__page", ""))
    {
      $this->curentForm        = request::getValue("__page", "");
      $this->formType          = app::AGE_TYPE_PAGE;

    } else if(request::getValue("__special_app_page", ""))
    {
      $this->curentForm        = request::getValue("__special_app_page", "");
      $this->formType          = app::PAGE_TYPE_SPECIAL_APP;

    } else if(request::getValue("__special_page", ""))
    {  $this->curentForm        = request::getValue("__special_page", "");
      $this->formType          = app::PAGE_TYPE_SPECIAL;

    } else if(isset($_SESSION["__form"]) && $_SESSION["__form"])
    { $this->curentForm        = $_SESSION["__form"];
      $this->formType          = $_SESSION["__formType"];
      $toSession               = true;
    } else
    {
      $this->curentForm        = config::APP_START_PAGE;// $cfg->getSetting(config::APP_START_PAGE);// config::getInstance()->getSetting($name);
      $this->formType          = config::APP_START_PAGE_TYPE;// config::getInstance()->sys_START_PAGE_TYPE;
      $toSession               = true;
    }
    if($toSession)
    {
      $_SESSION["__form"]        = $this->curentForm;
      $_SESSION["__formType"]    = $this->formType;
    }
  }



}